/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jnet;

/**
 *
 * @author work
 */
import java.awt.Image;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.SwingWorker;
import static jnet.JNet.dialogMessage;
import static jnet.JNet.getImage;

public class ConnectionCheckWorker extends SwingWorker {

    @Override
    protected Integer doInBackground() throws Exception {





        while (!JNet.isExit) {

            if (!JNet.testInet("google.com")) {
                /////chanage to na...
                JNet.dialogMessage = JNet.problemMessage;
                JNet.trayIcon.setImage(JNet.problemImage);
                if (JNet.isOnline) {
                    JNet.trayIcon.displayMessage("jNet",
                            "OOPS! Internet connection seems to be lost",
                            TrayIcon.MessageType.INFO);
                    JNet.isOnline = Boolean.FALSE;
                }

            } else {
                ////change to available
                JNet.dialogMessage = JNet.okMessage;
                JNet.trayIcon.setImage(JNet.okImage);
                if (!JNet.isOnline) {
                    JNet.trayIcon.displayMessage("jNet",
                            "You are back online!",
                            TrayIcon.MessageType.INFO);
                    JNet.isOnline = Boolean.TRUE;
                }

            }

            Thread.sleep(3000);
        }
        return 1;
    }
}